package com.buildings.activity;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.TextureView;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.bigkoo.pickerview.OptionsPickerView;
import com.buildings.R;
import com.buildings.api.Api;
import com.buildings.api.Constant;
import com.buildings.base.BaseActivity;
import com.buildings.base.BaseFormActivity;
import com.buildings.bean.AddressBean;
import com.buildings.bean.DivisionResultBean;
import com.buildings.bean.ImageURL;
import com.buildings.bean.LoginBean;
import com.buildings.bean.TownHouseBean;
import com.buildings.bean.TownHouseResultBean;
import com.buildings.http.BaseCallBack;
import com.buildings.http.JsonBuilder;
import com.buildings.http.MyHttpClient;
import com.buildings.util.Base64Test;
import com.buildings.util.CustomToast;
import com.buildings.util.DataUtils;
import com.buildings.util.DialogUtils;
import com.buildings.util.FormDataUtil;
import com.buildings.util.PickViewUtil;
import com.buildings.util.SPUtil;
import com.buildings.util.Utils;
import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.google.gson.JsonObject;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.w3c.dom.Text;

import java.io.IOException;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * 城镇住宅表单
 */
public class TownHouseFormActivity extends BaseFormActivity {

  public static final String TOWN_HOUSER = "townHouse";

  @BindView(R.id.tv_title) TextView tvTitle;
  @BindView(R.id.tv_right_text) TextView tvSave;
  @BindView(R.id.tv_left_text) TextView tvClear;
  @BindView(R.id.iv_back) ImageView ivBack;
  @BindView(R.id.et_building_number) EditText etNumber;//建筑物编号
  @BindView(R.id.et_lng) EditText etLng;//经度
  @BindView(R.id.et_lat) EditText etLat;//纬度
  @BindView(R.id.et_building_type) EditText etBuildingType;//被调查建筑物分类
  @BindView(R.id.et_province) EditText etProvince;//省市区
  @BindView(R.id.et_city) EditText etCity;//省市区
  @BindView(R.id.et_area) EditText etArea;//省市区
  @BindView(R.id.et_building_street) EditText etBuidingStreet;//路，街名
  @BindView(R.id.et_house_number) EditText etHouseNumber;//小区门牌号
  @BindView(R.id.et_xiaoqu_name) EditText etXiaoQuName;//小区名称
  @BindView(R.id.et_building_name) EditText etBuildingName;//建筑名称
  @BindView(R.id.et_building_address) EditText etBuildingAddress;//建筑地址
  @BindView(R.id.et_chanquandanwei) EditText etChanQuanDanWei;//产权单位
  @BindView(R.id.et_jiegouleixing) EditText etJieGouLeiXing;//结构类型
  @BindView(R.id.et_jiegouleixing_qita) EditText getEtJieGouLeiXingQiTa;//结构类型其他
  @BindView(R.id.et_jianzhumianji) EditText etJianZhuMianJi;//建筑面积
  @BindView(R.id.et_dishangcengshu) EditText etDiShangCengShu;//建筑地上层数
  @BindView(R.id.et_dixiacengshu) EditText etDiXiaCengShu;//建筑地下层数
  @BindView(R.id.et_jianzhugaodu) EditText etJianZhuGaoDu;//建筑高度
  @BindView(R.id.et_jianzaoshijian) EditText etJianZaoShiJian;//建造时间
  @BindView(R.id.et_hushu) EditText etHuShu;//户数
  @BindView(R.id.et_renshu) EditText etRenShu;//人数
  @BindView(R.id.et_yuanshefangliedu) EditText etYuanSheFangLieDu;//原设防烈度
  @BindView(R.id.et_gaizao) EditText etGaiZaoShiJian;//改造时间
  @BindView(R.id.et_kangzhenjiagu) EditText etKangZhenJiaGu;//抗震加固时间
  @BindView(R.id.et_xianshefangliedu) EditText etXianSheFangLieDu;//现设防烈度
  @BindView(R.id.et_liefengbianxing) EditText etLieFengBianXing;//裂缝变形倾斜
  @BindView(R.id.et_wuyeguanli) EditText etWuYeGuanLi;//有无物业管理
  @BindView(R.id.rg_jielun) RadioGroup rgJieLun;//初步结论

  @BindView(R.id.iv_image) ImageView ivImage;//图片
  @BindView(R.id.iv_image_delete) ImageView ivImageDelete;
  @BindView(R.id.gv_pic) GridView gvPic;

  @BindView(R.id.btn_commit) Button btnCommit;//提交

  @BindView(R.id.tv_reason) TextView tvReason;//审核未通过原因

  @BindView(R.id.ll_item) LinearLayout llItem;

  @BindView(R.id.ll_more) LinearLayout llMore;
  @BindView(R.id.ll_item_more) LinearLayout llItemMore;
  @BindView(R.id.ll_gone) LinearLayout llGone;
  @BindView(R.id.ll_item_gone) LinearLayout llItemGone;
  @BindView(R.id.tv_gone) TextView tvGone;
  @BindView(R.id.iv_gone) ImageView ivGone;
  @BindView(R.id.tv_more) TextView tvMore;
  @BindView(R.id.iv_more) ImageView ivMore;

  @BindView(R.id.rb1) CheckBox checkBox1;
  @BindView(R.id.rb2) CheckBox checkBox2;
  @BindView(R.id.rb3) CheckBox checkBox3;
  @BindView(R.id.rb4) CheckBox checkBox4;
  private String result1 = "";
  private String result2 = "";
  private String result3 = "";
  private String result4 = "";

  //点击经纬度
  private String lng;
  private String lat;
  private String taskId;
  private String taskName;

  private String formId;//表单id  只有在表单列表才会传递，用于修改表单

  private String buildType;
  private String userId;

  private String from;//从哪个界面过来的标识
  private boolean isEdit;//标识是否可编辑   true可编辑
  private boolean isFirst;//标识是否是第一次创建表单  true是
  private String imageUrl;

  @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_town_house_new);
    ButterKnife.bind(this);
    initView();
    initData();
  }

  private void initView() {
    tvTitle.setText("城镇住宅表单");
    etDiShangCengShu.addTextChangedListener(new TextWatcher() {
      @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {

      }

      @Override public void onTextChanged(CharSequence s, int start, int before, int count) {

      }

      @Override public void afterTextChanged(Editable s) {
        if (!TextUtils.isEmpty(s.toString())) {
          int a = Integer.parseInt(s.toString());//地上层数
          etJianZhuGaoDu.setText(a * 3 + "");
        } else {
          etJianZhuGaoDu.setText("");
        }
      }
    });
    etHuShu.addTextChangedListener(new TextWatcher() {
      @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {

      }

      @Override public void onTextChanged(CharSequence s, int start, int before, int count) {

      }

      @Override public void afterTextChanged(Editable s) {
        if (!TextUtils.isEmpty(s.toString())) {
          int a = Integer.parseInt(s.toString());//户数
          int result = (int) (a * 3.5);
          etRenShu.setText(result + "");
        } else {
          etRenShu.setText("");
        }
      }
    });
    etJieGouLeiXing.addTextChangedListener(new TextWatcher() {
      @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

      }

      @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

      }

      @Override public void afterTextChanged(Editable editable) {
        if (TextUtils.equals("其它", editable.toString())) {
          getEtJieGouLeiXingQiTa.setVisibility(View.VISIBLE);
        } else {
          getEtJieGouLeiXingQiTa.setVisibility(View.GONE);
        }
      }
    });
    checkBox1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
      @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked) {
          result1 = Constant.FORM_RESULT_01;
        } else {
          result1 = "";
        }
      }
    });
    checkBox2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
      @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked) {
          result2 = Constant.FORM_RESULT_02;
        } else {
          result2 = "";
        }
      }
    });
    checkBox3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
      @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked) {
          result3 = Constant.FORM_RESULT_03;
        } else {
          result3 = "";
        }
      }
    });
    checkBox4.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
      @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked) {
          result4 = Constant.FORM_RESULT_04;
        } else {
          result4 = "";
        }
      }
    });

    initLayoutPicture(gvPic);
  }

  private void initEditTextContent(boolean isShowLast) {

    etBuildingType.setText(FormDataUtil.getBuildingType().get(0));
    etJieGouLeiXing.setText(FormDataUtil.getJieGouLeiXing().get(0));
    etJianZaoShiJian.setText(FormDataUtil.getJianZaoShiJian().get(0));
    etYuanSheFangLieDu.setText(FormDataUtil.getYuanSheFangLieDu().get(0));
    etGaiZaoShiJian.setText(FormDataUtil.getGaiZaoShiJian().get(0));
    etKangZhenJiaGu.setText(FormDataUtil.getKangZhenJiaGu().get(0));
    etXianSheFangLieDu.setText(FormDataUtil.getXianSheFangLieDu().get(0));
    etLieFengBianXing.setText(FormDataUtil.getLieFengBianXing().get(0));
    etWuYeGuanLi.setText(FormDataUtil.getLieFengBianXing().get(0));

    etBuidingStreet.setText("");
    etHouseNumber.setText("");
    etXiaoQuName.setText("");
    etBuildingName.setText("");
    etBuildingAddress.setText("");
    etChanQuanDanWei.setText("未知");
    getEtJieGouLeiXingQiTa.setText("");
    etJianZhuMianJi.setText("0");
    etDiShangCengShu.setText("0");
    etDiXiaCengShu.setText("0");
    etJianZhuGaoDu.setText("0");
    etHuShu.setText("0");
    etRenShu.setText("0");
    checkBox1.setChecked(false);
    checkBox2.setChecked(false);
    checkBox3.setChecked(false);
    checkBox4.setChecked(false);
    result1 = "";
    result2 = "";
    result3 = "";
    result4 = "";

    imageUrl = "";

    //        ivImage.setImageResource(R.mipmap.ic_picture);
    clearImage();

    if (isShowLast) {
      String json = (String) SPUtil.get(TOWN_HOUSER, "");
      if (!TextUtils.isEmpty(json)) {
        Gson gson = new Gson();
        TownHouseBean bean = gson.fromJson(json, TownHouseBean.class);
        //            etNumber.setText(bean.getBuildingCode());
        //            lng = bean.getBulidingLongitude();
        //            lat = bean.getBulidingLatitude();
        //            etLng.setText(bean.getBulidingLongitude());
        //            etLat.setText(bean.getBulidingLatitude());
        //            etBuildingType.setText(bean.getBulidingType());

        //            province = bean.getBelongtoProvince();
        //            city = bean.getBelongtoCity();
        //            area = bean.getBelongtoArea();
        //            if(!TextUtils.isEmpty(province)){
        //                etProvince.setText(province);
        //            }else {
        //                etProvince.setText("");
        //            }
        //            if(!TextUtils.isEmpty(city)){
        //                etCity.setText(city);
        //            }else {
        //                etCity.setText("");
        //            }
        //            if(!TextUtils.isEmpty(area)){
        //                etArea.setText(area);
        //            }else {
        //                etArea.setText("");
        //            }

        etBuidingStreet.setText(bean.getBelongtoStreet());
        etHouseNumber.setText(bean.getHouseNumber());
        etXiaoQuName.setText(bean.getAreaName());
        //etBuildingAddress.setText(bean.getBuildingAddress());
        //etBuildingName.setText(bean.getBuildingName());
        etChanQuanDanWei.setText(bean.getPropertyUnit());

        //房屋结构类型其他
        etJieGouLeiXing.setText(bean.getStructureType());
        if (TextUtils.equals("其它", bean.getStructureType())) {
          getEtJieGouLeiXingQiTa.setVisibility(View.VISIBLE);
          getEtJieGouLeiXingQiTa.setText(bean.getStructureTypeOther());
        } else {
          getEtJieGouLeiXingQiTa.setVisibility(View.GONE);
        }

        etJianZhuMianJi.setText(bean.getBuildingArea() + "");
        etDiShangCengShu.setText(bean.getBuildingUpNum() + "");
        etDiXiaCengShu.setText(bean.getBuildingDown() + "");
        etJianZhuGaoDu.setText(bean.getBuildingHight() + "");
        etJianZaoShiJian.setText(bean.getBuildingTime() + "");
        etHuShu.setText(bean.getHouseNum() + "");
        etRenShu.setText(bean.getPresonNum() + "");
        etYuanSheFangLieDu.setText(bean.getOldFortificationIntensity());
        etGaiZaoShiJian.setText(bean.getIsReform());
        etKangZhenJiaGu.setText(bean.getIsSeismicReinforce());
        etXianSheFangLieDu.setText(bean.getNowFortificationIntensity());
        etLieFengBianXing.setText(bean.getIsDamage());
        etWuYeGuanLi.setText(bean.getIsManagement());
        //            imageUrl = bean.getImage();
        //            Glide.with(activity).load(imageUrl).asBitmap().centerCrop().error(R.mipmap.ic_picture).into(ivImage);
        //                updateImage(new ArrayList<ImageURL>() );

        String result = bean.getResult();
        if (!TextUtils.isEmpty(result)) {
          String[] array = result.split(",");
          for (String str : array) {
            switch (str) {
              case Constant.FORM_RESULT_01:
                result1 = str;
                checkBox1.setChecked(true);
                break;
              case Constant.FORM_RESULT_02:
                result2 = str;
                checkBox2.setChecked(true);
                break;
              case Constant.FORM_RESULT_03:
                result3 = str;
                checkBox3.setChecked(true);
                break;
              case Constant.FORM_RESULT_04:
                result4 = str;
                checkBox4.setChecked(true);
                break;
            }
          }
        }
      }
    }
  }

  private void initData() {
    lng = getIntent().getStringExtra("lng");
    lat = getIntent().getStringExtra("lat");
    //        locationLng = getIntent().getStringExtra("locationLng");
    //        locationLat = getIntent().getStringExtra("locationLat");
    taskId = getIntent().getStringExtra("taskId");
    taskName = getIntent().getStringExtra("taskName");
    formId = getIntent().getStringExtra("formId");
    buildType = getIntent().getStringExtra("buildType");
    from = getIntent().getStringExtra("from");
    userId = (String) SPUtil.get("userId", "");

    isEdit = getIntent().getBooleanExtra("isEdit", true);
    isFirst = getIntent().getBooleanExtra("isFirst", false);

    tvSave.setText("保存");
    tvSave.setVisibility(View.VISIBLE);
    tvClear.setText("清空");
    tvClear.setVisibility(View.VISIBLE);
    if (TextUtils.equals(TaskMapActivity.FROM_TASK_MAP, from)) {

      if (isFirst) {
        initEditTextContent(true);//第一次创建，显示默认值
        getTianDiTuLocation(lng, lat, etBuildingAddress, etProvince, etCity, etArea, etBuildingName,
            etNumber, etBuidingStreet, etHouseNumber);
      } else {
        getFormData(buildType, formId);

        if (isEdit) {
          //点击地图标识查看表单, 而且可编辑
        } else {
          //不可编辑
          setEnabled();
        }
      }
    } else {
      checkBox1.setChecked(false);
      result1 = "";
      getFormData(buildType, formId);
      if (isEdit) {
        //可编辑
      } else {
        //不可编辑
        setEnabled();
      }

      //            String dd = "{\"code\":200,\"data\":{\"fwId\":\"d3d8099452de4435ab2107d09052fc3a\",\"taskId\":\"2\",\"buildingCode\":\"140728202005203\",\"bulidingLongitude\":\"112.08078\",\"bulidingLatitude\":\"37.24162\",\"bulidingType\":\"既有\",\"belongtoProvince\":\"山西省\",\"belongtoCity\":\"晋中市\",\"belongtoArea\":\"平遥县\",\"belongtoStreet\":\"\",\"belongtoTown\":null,\"propertyNature\":null,\"belongtoVillage\":null,\"houseNumber\":\"\",\"areaName\":\"\",\"buildingName\":\"城镇住宅\",\"buildingAddress\":\"晋中市梁家堡-北侯公路西南202.0米\",\"propertyUnit\":\"\",\"structureType\":\"砖混\",\"structureTypeOther\":null,\"buildingArea\":0,\"buildingUpNum\":0,\"buildingDown\":0,\"buildingHight\":0,\"buildingTime\":\"70s以前\",\"houseNum\":0,\"presonNum\":0,\"oldFortificationIntensity\":\"未设防\",\"isReform\":\"未改造\",\"isSeismicReinforce\":\"未加固\",\"nowFortificationIntensity\":\"未设防\",\"isDamage\":\"有\",\"isManagement\":\"有\",\"result\":\"未抗震设防\",\"image\":null,\"collecPerson\":null,\"unit\":null,\"collecDate\":null,\"oldFortificationType\":null,\"nowFortificationType\":null,\"housePurpose\":null,\"saveStatus\":\"0\",\"createTime\":\"2020-05-19T16:00:00.000+0000\",\"createUserId\":null,\"isSaveAll\":\"0\",\"isValid\":\"1\",\"spType\":\"0\",\"taskName\":\"31\"},\"message\":null}";
      //            Gson gson = new Gson();
      //            TownHouseBean bean = gson.fromJson(dd,TownHouseResultBean.class).getData();
      //            etNumber.setText(bean.getBuildingCode());
      //            lng = bean.getBulidingLongitude();
      //            lat = bean.getBulidingLatitude();
      //            etLng.setText(bean.getBulidingLongitude());
      //            etLat.setText(bean.getBulidingLatitude());
      //            etBuildingType.setText(bean.getBulidingType());
      //
      //            province = bean.getBelongtoProvince();
      //            city = bean.getBelongtoCity();
      //            area = bean.getBelongtoArea();
      //            if(!TextUtils.isEmpty(province)){
      //                etProvince.setText(province);
      //            }else {
      //                etProvince.setText("");
      //            }
      //            if(!TextUtils.isEmpty(city)){
      //                etCity.setText(city);
      //            }else {
      //                etCity.setText("");
      //            }
      //            if(!TextUtils.isEmpty(area)){
      //                etArea.setText(area);
      //            }else {
      //                etArea.setText("");
      //            }
      //
      //            etBuidingStreet.setText(bean.getBelongtoStreet());
      //            etHouseNumber.setText(bean.getHouseNumber());
      //            etXiaoQuName.setText(bean.getAreaName());
      //            etBuildingAddress.setText(bean.getBuildingAddress());
      //            etBuildingName.setText(bean.getBuildingName());
      //            etChanQuanDanWei.setText(bean.getPropertyUnit());
      //
      //            //房屋结构类型其他
      //            etJieGouLeiXing.setText(bean.getStructureType());
      //            getEtJieGouLeiXingQiTa.setText(bean.getStructureTypeOther());
      //
      //            etJianZhuMianJi.setText(bean.getBuildingArea()+"");
      //            etDiShangCengShu.setText(bean.getBuildingUpNum()+"");
      //            etDiXiaCengShu.setText(bean.getBuildingDown()+"");
      //            etJianZhuGaoDu.setText(bean.getBuildingHight()+"");
      //            etJianZaoShiJian.setText(bean.getBuildingTime()+"");
      //            etHuShu.setText(bean.getHouseNum()+"");
      //            etRenShu.setText(bean.getPresonNum()+"");
      //            etYuanSheFangLieDu.setText(bean.getOldFortificationIntensity());
      //            etGaiZaoShiJian.setText(bean.getIsReform());
      //            etKangZhenJiaGu.setText(bean.getIsSeismicReinforce());
      //            etXianSheFangLieDu.setText(bean.getNowFortificationIntensity());
      //            etLieFengBianXing.setText(bean.getIsDamage());
      //            etWuYeGuanLi.setText(bean.getIsManagement());
      //            imageUrl = bean.getImage();
      //            Glide.with(activity).load(imageUrl).asBitmap().error(R.mipmap.ic_picture).into(ivImage);
      //
      //            String result = bean.getResult();
      //            if(!TextUtils.isEmpty(result)){
      //                String[] array = result.split(",");
      //                for(String str : array){
      //                    switch (str){
      //                        case Constant.FORM_RESULT_01:
      //                            result1 = str;
      //                            checkBox1.setChecked(true);
      //                            break;
      //                        case Constant.FORM_RESULT_02:
      //                            result2 = str;
      //                            checkBox2.setChecked(true);
      //                            break;
      //                        case Constant.FORM_RESULT_03:
      //                            result3 = str;
      //                            checkBox3.setChecked(true);
      //                            break;
      //                        case Constant.FORM_RESULT_04:
      //                            result4 = str;
      //                            checkBox4.setChecked(true);
      //                            break;
      //                    }
      //                }
      //            }

    }
    //上传活动轨迹
    updateLocation();

    etLng.setText(lng);
    etLat.setText(lat);
  }

  /**
   * 所有控件不可点击编辑
   */
  private void setEnabled() {
    tvSave.setVisibility(View.INVISIBLE);
    tvClear.setVisibility(View.INVISIBLE);
    btnCommit.setVisibility(View.INVISIBLE);

    etBuildingType.setEnabled(false);
    etProvince.setEnabled(false);
    etCity.setEnabled(false);
    etArea.setEnabled(false);
    etBuidingStreet.setEnabled(false);
    etHouseNumber.setEnabled(false);
    etXiaoQuName.setEnabled(false);
    etBuildingName.setEnabled(false);
    etBuildingAddress.setEnabled(false);
    etChanQuanDanWei.setEnabled(false);
    etJieGouLeiXing.setEnabled(false);
    getEtJieGouLeiXingQiTa.setEnabled(false);
    etJianZhuMianJi.setEnabled(false);
    etDiShangCengShu.setEnabled(false);
    etDiXiaCengShu.setEnabled(false);
    etJianZhuGaoDu.setEnabled(false);
    etJianZaoShiJian.setEnabled(false);
    etHuShu.setEnabled(false);
    etRenShu.setEnabled(false);
    etYuanSheFangLieDu.setEnabled(false);
    etGaiZaoShiJian.setEnabled(false);
    etKangZhenJiaGu.setEnabled(false);
    etXianSheFangLieDu.setEnabled(false);
    etLieFengBianXing.setEnabled(false);
    etWuYeGuanLi.setEnabled(false);
    checkBox1.setClickable(false);
    checkBox2.setClickable(false);
    checkBox3.setClickable(false);
    checkBox4.setClickable(false);
    ivImage.setEnabled(false);
    gvPic.setEnabled(false);
  }

  @Override public void myLocation(String locationLng, String locationLat) {
    super.myLocation(locationLng, locationLat);
    updateFoot(userId, taskId, locationLng, locationLat);
  }

  @OnClick({
      R.id.iv_back, R.id.et_building_type, R.id.et_province, R.id.et_city, R.id.et_area,
      R.id.et_jiegouleixing, R.id.et_jianzaoshijian, R.id.et_yuanshefangliedu, R.id.et_gaizao,
      R.id.et_kangzhenjiagu, R.id.et_xianshefangliedu, R.id.et_liefengbianxing, R.id.et_wuyeguanli,
      R.id.btn_commit, R.id.tv_right_text, R.id.tv_left_text, R.id.ll_item, R.id.ll_more,
      R.id.ll_gone, R.id.iv_image_delete, R.id.iv_image
  }) public void onClick(View v) {
    Utils.hintKb(activity);
    switch (v.getId()) {
      case R.id.iv_back:
        finish();
        break;
      case R.id.tv_left_text:
        //清空
        initEditTextContent(false);
        CustomToast.showToast(activity, "已清空内容");
        break;
      case R.id.ll_gone:
        //隐藏信息
        if (llItemGone.getVisibility() == View.VISIBLE) {
          llItemGone.setVisibility(View.GONE);
          tvGone.setText("基本信息");
          ivGone.setImageResource(R.mipmap.ic_bottom_tri);
        } else {
          llItemGone.setVisibility(View.VISIBLE);
          tvGone.setText("隐藏信息");
          ivGone.setImageResource(R.mipmap.ic_top_tri);
        }
        break;
      case R.id.ll_more:
        //更多信息
        if (llItemMore.getVisibility() == View.VISIBLE) {
          llItemMore.setVisibility(View.GONE);
          ivMore.setImageResource(R.mipmap.ic_bottom_tri);
        } else {
          llItemMore.setVisibility(View.VISIBLE);
          ivMore.setImageResource(R.mipmap.ic_top_tri);
        }
        break;
      case R.id.et_building_type:
        //建筑分类
        final List<String> typeList = FormDataUtil.getBuildingType();
        PickViewUtil.showPickerViewOne(activity, "", typeList,
            new OptionsPickerView.OnOptionsSelectListener() {
              @Override
              public void onOptionsSelect(int options1, int options2, int options3, View v) {
                String type = typeList.get(options1);
                etBuildingType.setText(type);
              }
            });
        break;
      case R.id.et_province:
        //省市区
        getDivisions("root", RegisterActivity.PROVINCE, "", null);
        break;
      case R.id.et_city:
        //省市区
        if (provinceBean == null) {
          CustomToast.showToast(activity, "请先选择省");
          return;
        }

        getDivisions(provinceBean.getDivisionId(), RegisterActivity.CITY,
            provinceBean.getDivisionType(), provinceBean);
        break;
      case R.id.et_area:
        if (cityBean == null) {
          CustomToast.showToast(activity, "请先选择市");
          return;
        }
        //省市区
        getDivisions(cityBean.getDivisionId(), RegisterActivity.AREA, "", null);
        break;
      //            case R.id.et_building_street:
      //                //街道
      //
      //                break;
      case R.id.et_jiegouleixing:
        //结构类型
        final List<String> jglxList = FormDataUtil.getJieGouLeiXing();
        PickViewUtil.showPickerViewOne(activity, "", jglxList,
            new OptionsPickerView.OnOptionsSelectListener() {
              @Override
              public void onOptionsSelect(int options1, int options2, int options3, View v) {
                String type = jglxList.get(options1);
                etJieGouLeiXing.setText(type);
              }
            });
        break;
      case R.id.et_jianzaoshijian:
        //建造时间
        final List<String> jzsjList = FormDataUtil.getJianZaoShiJian();
        PickViewUtil.showPickerViewOne(activity, "", jzsjList,
            new OptionsPickerView.OnOptionsSelectListener() {
              @Override
              public void onOptionsSelect(int options1, int options2, int options3, View v) {
                String type = jzsjList.get(options1);
                etJianZaoShiJian.setText(type);
              }
            });
        break;
      case R.id.et_yuanshefangliedu:
        //原设防烈度
        final List<String> ysfldList = FormDataUtil.getYuanSheFangLieDu();
        PickViewUtil.showPickerViewOne(activity, "", ysfldList,
            new OptionsPickerView.OnOptionsSelectListener() {
              @Override
              public void onOptionsSelect(int options1, int options2, int options3, View v) {
                String type = ysfldList.get(options1);
                etYuanSheFangLieDu.setText(type);
                if (TextUtils.equals("未改造", etGaiZaoShiJian.getText().toString())) {
                  etXianSheFangLieDu.setText(type);
                }
              }
            });
        break;
      case R.id.et_gaizao://改造时间
        final List<String> gzsjList = FormDataUtil.getGaiZaoShiJian();
        PickViewUtil.showPickerViewOne(activity, "", gzsjList,
            new OptionsPickerView.OnOptionsSelectListener() {
              @Override
              public void onOptionsSelect(int options1, int options2, int options3, View v) {
                String type = gzsjList.get(options1);
                etGaiZaoShiJian.setText(type);
                setCommonText();
              }
            });
        break;
      case R.id.et_kangzhenjiagu://抗震加固时间
        final List<String> kzjgList = FormDataUtil.getKangZhenJiaGu();
        PickViewUtil.showPickerViewOne(activity, "", kzjgList,
            new OptionsPickerView.OnOptionsSelectListener() {
              @Override
              public void onOptionsSelect(int options1, int options2, int options3, View v) {
                String type = kzjgList.get(options1);
                etKangZhenJiaGu.setText(type);
              }
            });
        break;
      case R.id.et_xianshefangliedu://现设防烈度
        final List<String> xsfld = FormDataUtil.getXianSheFangLieDu();
        PickViewUtil.showPickerViewOne(activity, "", xsfld,
            new OptionsPickerView.OnOptionsSelectListener() {
              @Override
              public void onOptionsSelect(int options1, int options2, int options3, View v) {
                String type = xsfld.get(options1);
                etXianSheFangLieDu.setText(type);
              }
            });
        break;
      case R.id.et_liefengbianxing://裂缝变形倾斜
        final List<String> lfbx = FormDataUtil.getLieFengBianXing();
        PickViewUtil.showPickerViewOne(activity, "", lfbx,
            new OptionsPickerView.OnOptionsSelectListener() {
              @Override
              public void onOptionsSelect(int options1, int options2, int options3, View v) {
                String type = lfbx.get(options1);
                etLieFengBianXing.setText(type);
              }
            });
        break;
      case R.id.et_wuyeguanli://物业管理
        final List<String> wygl = FormDataUtil.getLieFengBianXing();
        PickViewUtil.showPickerViewOne(activity, "", wygl,
            new OptionsPickerView.OnOptionsSelectListener() {
              @Override
              public void onOptionsSelect(int options1, int options2, int options3, View v) {
                String type = wygl.get(options1);
                etWuYeGuanLi.setText(type);
              }
            });
        break;
      case R.id.iv_image://图片
        //                if(myDialog == null){
        //                    myDialog = DialogUtils.showRefreshDialog(activity);
        //                }else {
        //                    myDialog.show();
        //                }
        selectImage();
        break;
      case R.id.iv_image_delete:
        //删除图片
        imageUrl = "";
        Glide.with(activity).load(imageUrl).asBitmap().error(R.mipmap.ic_picture).into(ivImage);
        break;
      case R.id.btn_commit://提交
        String content = isComplete();
        if (!TextUtils.isEmpty(content)) {
          CustomToast.showToast(activity, content);
          return;
        }
        DialogUtils.showIOSDialog(activity, "提示", "", "", "", "", null, new View.OnClickListener() {
          @Override public void onClick(View view) {
            updateLocation();//上传活动轨迹
            if (myDialog == null) {
              myDialog = DialogUtils.showRefreshDialog(activity);
            } else {
              myDialog.show();
            }

            myDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
              @Override public void onDismiss(DialogInterface dialog) {
                btnCommit.setEnabled(true);
              }
            });

            btnCommit.setEnabled(false);

            //0、暂存1、提交
            //是否填完0、否1、是
            commit("1", "1");
          }
        }, "确定要提交当前表单？");

        break;
      case R.id.tv_right_text:
        //0、暂存1、提交
        //是否填完0、否  1、是
        if (TextUtils.isEmpty(etNumber.getText().toString())) {
          //建筑物编号为空，不能保存操作
          CustomToast.showToast(activity, "没有建筑物编号，无法保存，请重新进入该界面");
          return;
        }
        tvSave.setEnabled(false);
        if (myDialog == null) {
          myDialog = DialogUtils.showRefreshDialog(activity);
        } else {
          myDialog.show();
        }
        updateLocation();//上传活动轨迹
        String str = isComplete();
        String isComplete = "0";
        if (TextUtils.isEmpty(str)) {
          //填完整的保存
          isComplete = "1";
        } else {
          isComplete = "0";
        }
        commit("0", isComplete);
        break;
    }
  }

  private void getFormData(final String buildType, String formId) {
    String url = Api.FORM + "?type=" + buildType + "&formId=" + formId;
    MyHttpClient.newBuilder().get().url(url)
        //                .addParam(json)
        .build().enqueue(new BaseCallBack<TownHouseResultBean>() {
      @Override public void onSuccess(TownHouseResultBean resultBean) {
        super.onSuccess(resultBean);
        if (resultBean.getCode() == 200 && resultBean.getData() != null) {
          TownHouseBean bean = resultBean.getData();
          etNumber.setText(bean.getBuildingCode());
          buildingCode = bean.getBuildingCode();
          lng = bean.getBulidingLongitude();
          lat = bean.getBulidingLatitude();
          etLng.setText(bean.getBulidingLongitude());
          etLat.setText(bean.getBulidingLatitude());
          etBuildingType.setText(bean.getBulidingType());

          province = bean.getBelongtoProvince();
          city = bean.getBelongtoCity();
          area = bean.getBelongtoArea();
          if (!TextUtils.isEmpty(province)) {
            etProvince.setText(province);
          } else {
            etProvince.setText("");
          }
          if (!TextUtils.isEmpty(city)) {
            etCity.setText(city);
          } else {
            etCity.setText("");
          }
          if (!TextUtils.isEmpty(area)) {
            etArea.setText(area);
          } else {
            etArea.setText("");
          }

          etBuidingStreet.setText(bean.getBelongtoStreet());
          etHouseNumber.setText(bean.getHouseNumber());
          etXiaoQuName.setText(bean.getAreaName());
          etBuildingAddress.setText(bean.getBuildingAddress());
          etBuildingName.setText(bean.getBuildingName());
          etChanQuanDanWei.setText(bean.getPropertyUnit());

          //房屋结构类型其他
          etJieGouLeiXing.setText(bean.getStructureType());
          getEtJieGouLeiXingQiTa.setText(bean.getStructureTypeOther());

          etJianZhuMianJi.setText(bean.getBuildingArea() + "");
          etDiShangCengShu.setText(bean.getBuildingUpNum() + "");
          etDiXiaCengShu.setText(bean.getBuildingDown() + "");
          etJianZhuGaoDu.setText(bean.getBuildingHight() + "");
          etJianZaoShiJian.setText(bean.getBuildingTime() + "");
          etHuShu.setText(bean.getHouseNum() + "");
          etRenShu.setText(bean.getPresonNum() + "");
          etYuanSheFangLieDu.setText(bean.getOldFortificationIntensity());
          etGaiZaoShiJian.setText(bean.getIsReform());
          etKangZhenJiaGu.setText(bean.getIsSeismicReinforce());
          etXianSheFangLieDu.setText(bean.getNowFortificationIntensity());
          etLieFengBianXing.setText(bean.getIsDamage());
          etWuYeGuanLi.setText(bean.getIsManagement());
          imageUrl = bean.getImage();

          //                            Glide.with(activity).load(imageUrl).asBitmap().error(R.mipmap.ic_picture).into(ivImage);
          //                            updateImage(new ArrayList<ImageURL>() );
          if (!TextUtils.isEmpty(imageUrl)) {
            String[] arrImage = imageUrl.split(",");
            if (listUrl == null) {
              listUrl = new ArrayList<ImageURL>();
            }
            for (String url : arrImage) {
              ImageURL imageURL = new ImageURL();
              imageURL.setLocalPath(url);
              imageURL.setThumbnail(url);
              listUrl.add(imageURL);
            }
            updateImage(listUrl);
          }

          //是否显示审核未通过提示
          if (!TextUtils.isEmpty(bean.getReason())) {
            tvReason.setVisibility(View.VISIBLE);
            tvReason.setText(bean.getReason());
          } else {
            tvReason.setVisibility(View.GONE);
          }

          String result = bean.getResult();
          if (!TextUtils.isEmpty(result)) {
            String[] array = result.split(",");
            for (String str : array) {
              switch (str) {
                case Constant.FORM_RESULT_01:
                  result1 = str;
                  checkBox1.setChecked(true);
                  break;
                case Constant.FORM_RESULT_02:
                  result2 = str;
                  checkBox2.setChecked(true);
                  break;
                case Constant.FORM_RESULT_03:
                  result3 = str;
                  checkBox3.setChecked(true);
                  break;
                case Constant.FORM_RESULT_04:
                  result4 = str;
                  checkBox4.setChecked(true);
                  break;
              }
            }
          }
        } else {
          CustomToast.showToast(activity, "获取表单内容失败");
        }
        if (myDialog != null) {
          myDialog.dismiss();
        }
      }

      @Override public void onFailure(Call call, IOException e) {
        super.onFailure(call, e);
        if (myDialog != null) {
          myDialog.dismiss();
        }
        CustomToast.showToast(activity, "网络异常");
      }

      @Override public void onError(int code) {
        super.onError(code);
        if (myDialog != null) {
          myDialog.dismiss();
        }
        CustomToast.showToast(activity, "网络异常");
      }
    });
  }

  private void commit(String type, String isComplete) {
    //从表单列表过来提交时的接口
    String url = Api.FORM_TOWN_HOUSE + type + "/updCity";
    if (isFirst) {
      //从地图第一次过来提交的接口
      url = Api.FORM_TOWN_HOUSE + type + "/saveCity";
    }

    TownHouseBean bean = new TownHouseBean();
    if (!TextUtils.isEmpty(formId)) {
      bean.setFwId(formId);
    }
    bean.setIsSaveAll(isComplete);//保存时是否是全部填写完
    bean.setTaskId(taskId);
    bean.setTaskName(taskName);
    bean.setBuildingCode(etNumber.getText().toString());
    bean.setBulidingLongitude(lng);
    bean.setBulidingLatitude(lat);
    bean.setBulidingType(etBuildingType.getText().toString());
    bean.setBelongtoProvince(province);
    bean.setBelongtoCity(city);
    bean.setBelongtoArea(area);
    bean.setBelongtoStreet(etBuidingStreet.getText().toString());
    bean.setHouseNumber(etHouseNumber.getText().toString());
    bean.setAreaName(etXiaoQuName.getText().toString());
    bean.setBuildingAddress(etBuildingAddress.getText().toString());
    bean.setBuildingName(etBuildingName.getText().toString());
    bean.setPropertyUnit(etChanQuanDanWei.getText().toString());
    if (TextUtils.equals("其它", etJieGouLeiXing.getText().toString())) {
      bean.setStructureType(etJieGouLeiXing.getText().toString());
      bean.setStructureTypeOther(getEtJieGouLeiXingQiTa.getText().toString());
    } else {
      bean.setStructureType(etJieGouLeiXing.getText().toString());
    }

    if (TextUtils.isEmpty(etJianZhuMianJi.getText().toString())) {
      etJianZhuMianJi.setText("0");
    }
    if (TextUtils.isEmpty(etDiShangCengShu.getText().toString())) {
      etDiShangCengShu.setText("0");
    }
    if (TextUtils.isEmpty(etDiXiaCengShu.getText().toString())) {
      etDiXiaCengShu.setText("0");
    }
    if (TextUtils.isEmpty(etJianZhuGaoDu.getText().toString())) {
      etJianZhuGaoDu.setText("0");
    }
    if (TextUtils.isEmpty(etHuShu.getText().toString())) {
      etHuShu.setText("0");
    }
    if (TextUtils.isEmpty(etRenShu.getText().toString())) {
      etRenShu.setText("0");
    }
    bean.setBuildingArea(Integer.parseInt(etJianZhuMianJi.getText().toString()));
    bean.setBuildingUpNum(Integer.parseInt(etDiShangCengShu.getText().toString()));
    bean.setBuildingDown(Integer.parseInt(etDiXiaCengShu.getText().toString()));
    bean.setBuildingHight(Integer.parseInt(etJianZhuGaoDu.getText().toString()));
    bean.setBuildingTime(etJianZaoShiJian.getText().toString());
    bean.setHouseNum(Integer.parseInt(etHuShu.getText().toString()));
    bean.setPresonNum(Integer.parseInt(etRenShu.getText().toString()));
    bean.setOldFortificationIntensity(etYuanSheFangLieDu.getText().toString());
    bean.setIsReform(etGaiZaoShiJian.getText().toString());
    bean.setIsSeismicReinforce(etKangZhenJiaGu.getText().toString());//抗震加固
    bean.setNowFortificationIntensity(etXianSheFangLieDu.getText().toString());
    bean.setIsDamage(etLieFengBianXing.getText().toString());
    bean.setIsManagement(etWuYeGuanLi.getText().toString());

    imageUrl = "";
    if (listUrl != null) {
      for (int i = 0; i < listUrl.size(); i++) {
        if (i == listUrl.size() - 1) {
          imageUrl = imageUrl + listUrl.get(i).getThumbnail();
        } else {
          imageUrl = imageUrl + listUrl.get(i).getThumbnail() + ",";
        }
      }
    }

    bean.setImage(imageUrl);

    String result = getResult();
    bean.setResult(result);

    Gson gson = new Gson();
    String json = gson.toJson(bean);
    //将最近的保存或提交内容保存本地，用于下次新创建表单时默认显示保存内容
    SPUtil.save(TOWN_HOUSER, json);

    MyHttpClient.newBuilder()
        .post()
        .url(url)
        .addParam(json)
        .build()
        .enqueue(new BaseCallBack<LoginBean>() {
          @Override public void onSuccess(LoginBean bean) {
            super.onSuccess(bean);
            //{"code":200,"data":{"success":true,"errorCode":null,"errorMessage":null,"retryTimes":0,"remainLockedTime":null,"userId":"ca3ca0d0d557424d94ec8009b6ca6d08","token":"eyJ0eXBlIjoiSldUIiwiYWxnIjoiSFMyNTYifQ.eyJqdGkiOiJhNGQ1MTkxZC01ZjY0LTQ5YjEtYTk4NS01NjM2YTA5ZDc1M2EiLCJpYXQiOjE1ODk1MzMxNDksInN1YiI6IjkzNWQ4MzNkZGU0MjRlMWJhYzdmZWVjM2M0MDZhMDI5IiwiZXhwIjoxNTg5NTMzNTQ5fQ.KGhav1E8SLuHXkb60RsbWj3xLMscIPrGmvDSmPjSLr4"},"message":null}
            if (bean.getCode() == 200) {
              CustomToast.showToast(activity, "保存成功");
              if (TextUtils.equals(TaskMapActivity.FROM_TASK_MAP, from)) {
                //地图过来的，回到任务列表
                //                                startActivity(new Intent(activity,TaskListActivity.class));
                setResult(RESULT_OK);
                finish();
              } else {
                //表单列表过来的回到 表单列表  刷新列表
                setResult(RESULT_OK);
                finish();
              }
            }else {
              tvSave.setEnabled(true);
            }
            if (myDialog != null) {
              myDialog.dismiss();
            }

          }

          @Override public void onFailure(Call call, IOException e) {
            super.onFailure(call, e);
            if (myDialog != null) {
              myDialog.dismiss();
            }
            CustomToast.showToast(activity, "网络异常");
            tvSave.setEnabled(true);

          }

          @Override public void onError(int code) {
            super.onError(code);
            if (myDialog != null) {
              myDialog.dismiss();
            }
            CustomToast.showToast(activity, "网络异常");
            tvSave.setEnabled(true);

          }
        });
  }

  /**
   * 最终的初步结论
   */
  private String getResult() {
    String str = "";
    if (!TextUtils.isEmpty(result1)) {
      str = str + result1 + ",";
    }
    if (!TextUtils.isEmpty(result2)) {
      str = str + result2 + ",";
    }
    if (!TextUtils.isEmpty(result3)) {
      str = str + result3 + ",";
    }
    if (!TextUtils.isEmpty(result4)) {
      str = str + result4 + ",";
    }
    if (!TextUtils.isEmpty(str)) {
      str = str.substring(0, str.length() - 1);
    }
    return str;
  }

  private String isComplete() {
    String content = "";
    if (TextUtils.equals("已拆除", etBuildingType.getText().toString())) {
      if (TextUtils.isEmpty(etNumber.getText().toString())) {
        content = "请输入建筑物编号";
        return content;
      }
      if (TextUtils.isEmpty(etLng.getText().toString())) {
        content = "请输入经度";
        return content;
      }
      if (TextUtils.isEmpty(etLat.getText().toString())) {
        content = "请输入纬度";
        return content;
      }
    } else {
      if (TextUtils.isEmpty(etNumber.getText().toString())) {
        content = "请输入建筑物编号";
        return content;
      }
      if (TextUtils.isEmpty(etLng.getText().toString())) {
        content = "请输入经度";
        return content;
      }
      if (TextUtils.isEmpty(etLat.getText().toString())) {
        content = "请输入纬度";
        return content;
      }
      if (TextUtils.isEmpty(etProvince.getText().toString())) {
        content = "请选择省";
        return content;
      }
      if (TextUtils.isEmpty(etCity.getText().toString())) {
        content = "请选择市";
        return content;
      }
      if (TextUtils.isEmpty(etArea.getText().toString())) {
        content = "请选择区";
        return content;
      }
      if (TextUtils.isEmpty(etBuidingStreet.getText().toString())) {
        content = "请输入街道";
        return content;
      }
      if (TextUtils.isEmpty(etHouseNumber.getText().toString())) {
        content = "请输入小区门牌号";
        return content;
      }
      if (TextUtils.isEmpty(etXiaoQuName.getText().toString())) {
        content = "请输入小区名称";
        return content;
      }
      if (TextUtils.isEmpty(etBuildingName.getText().toString())) {
        content = "请输入建筑名称";
        return content;
      }
      if (TextUtils.isEmpty(etBuildingAddress.getText().toString())) {
        content = "请输入建筑地址";
        return content;
      }
      if (TextUtils.isEmpty(etChanQuanDanWei.getText().toString())) {
        content = "请输入产权单位";
        return content;
      }
      if (TextUtils.isEmpty(etJieGouLeiXing.getText().toString())) {
        content = "请选择结构类型";
        return content;
      }
      if (TextUtils.equals("其它", etJieGouLeiXing.getText().toString())) {
        if (TextUtils.isEmpty(getEtJieGouLeiXingQiTa.getText().toString())) {
          content = "请输入其他结构类型的补充内容";
          return content;
        }
      }
      if (TextUtils.isEmpty(etJianZhuMianJi.getText().toString())) {
        content = "请输入建筑面积";
        return content;
      }
      if (TextUtils.isEmpty(etDiShangCengShu.getText().toString())) {
        content = "请输入建筑地上层数";
        return content;
      }
      if (TextUtils.isEmpty(etDiXiaCengShu.getText().toString())) {
        content = "请输入建筑地下层数";
        return content;
      }
      if (TextUtils.isEmpty(etJianZhuGaoDu.getText().toString())) {
        content = "请输入建筑高度";
        return content;
      }
      if (TextUtils.isEmpty(etJianZaoShiJian.getText().toString())) {
        content = "请选择建造时间";
        return content;
      }
      if (TextUtils.isEmpty(etHuShu.getText().toString())) {
        content = "请输入户数";
        return content;
      }
      if (TextUtils.isEmpty(etYuanSheFangLieDu.getText().toString())) {
        content = "请选择原设防烈度";
        return content;
      }
      if (TextUtils.isEmpty(etGaiZaoShiJian.getText().toString())) {
        content = "请选择改造时间";
        return content;
      }
      if (TextUtils.isEmpty(etKangZhenJiaGu.getText().toString())) {
        content = "请选择抗震加固时间";
        return content;
      }
      if (TextUtils.isEmpty(etWuYeGuanLi.getText().toString())) {
        content = "请选择有无物业管理";
        return content;
      }

      if (TextUtils.isEmpty(getResult())) {
        content = "请选择初步结论";
        return content;
      }

      //            if(TextUtils.isEmpty(imageUrl)){
      //                content = "请选择图片";
      //                return content;
      //            }
    }

    return content;
  }

  @Override public void setProvinceText(String province) {
    super.setProvinceText(province);
    etProvince.setText(province);
  }

  @Override public void setCityText(String city) {
    super.setCityText(city);
    etCity.setText(city);
  }

  @Override public void setAreaText(String area) {
    super.setAreaText(area);
    etArea.setText(area);
  }

  @Override public void setImage(String url) {
    super.setImage(url);
    //        imageUrl = url;
    //        Glide.with(activity).load(imageUrl).asBitmap().error(R.mipmap.ic_picture).into(ivImage);
  }

  private void setCommonText() {
    String text = etGaiZaoShiJian.getText().toString();
    if (TextUtils.equals("未改造", text)) {
      etXianSheFangLieDu.setText(etYuanSheFangLieDu.getText().toString());
    }
  }
}

